package com.sainan114.pipelinestudy.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lgb
 * @Date: 2021/7/10
 */
public class StrategyKeyValueMap {
    private final static Map<String , Object> strategyMap = new HashMap<>();

    // 策略对应的key
    private final static String ONLOAD_STRATEGY = "ONLOAD_STRATEGY";
    private final static String JUDGE_STRATEGY = "JUDGE_STRATEGY";
    private final static String MESSAGE_STRATEGY = "MESSAGE_STRATEGY";


    /**
     * 加载策略 一般存数据库查询出来DO对象的list
     * 我这边就使用String 来替代一下。
     */
    public static void setOnloadStrategy(List<String> list) {
        strategyMap.put(ONLOAD_STRATEGY, list);
    }

    public static List<String> getOnloadStrategy() {
        Object onloadDOList = strategyMap.get(ONLOAD_STRATEGY);
        if (onloadDOList != null && onloadDOList instanceof  List) {
            return (List<String>) onloadDOList;
        }
        return null;
    }

    /**
     * 判断策略 ：将加载策略的数据，根据ql表达式，来进行判断
     * 判断完毕后，将结果加入到数据库中
     * 正常也是使用DO的，这边用list来作为代替
     */
    public static void setJudgeStrategy(List<String> list) {
        strategyMap.put(JUDGE_STRATEGY, list);
    }

    public static List<String> getJudgeStrategy(){
        Object judgeDOList = strategyMap.get(JUDGE_STRATEGY);
        if (judgeDOList != null && judgeDOList instanceof List) {
            return (List<String>) judgeDOList;
        }
        return null;
    }
}
